package com.bdqn.zhao.controller;
import com.bdqn.zhao.pojo.EpActivity;
import com.bdqn.zhao.pojo.EpActivityimg;
import com.bdqn.zhao.service.EpActivityImgService;
import com.bdqn.zhao.service.EpActvityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/epActvity")
public class EpActvityController {
    @Autowired
    private EpActvityService epActvityService;
    @Autowired
    private EpActivityImgService epActivityImgService;
    @GetMapping("/selectAll")
    public String SelAllJ(HttpSession session,String ac_status,String status,String ac_name){
        List<EpActivity> epActvities = epActvityService.SelectAllJ(ac_status,status,ac_name);
        System.out.println("epActvities = " + epActvities);
        return "";
    }
    @DeleteMapping("/del/{id}")
    public Boolean delJ(@PathVariable int id){
        int i = epActvityService.delJ(id);
        if (i>0){
            return  true;
        }
            return false;

    }
    @GetMapping("/selectby/{id}")
    public String SeelctBysJ(@PathVariable int id){
        EpActivity epActivity = epActvityService.SelectByidJ(id);
        System.out.println("epActivity = " + epActivity);
        List<EpActivityimg> epActivityImgs=epActivityImgService.SelectBysJ(id);
        System.out.println("epActivityImgs = " + epActivityImgs);
        List<EpActivityimg> epActivityImgss=epActivityImgService.SelectBystJ(id);
        System.out.println("epActivityImgss = " + epActivityImgss);
    return "";
    }

    @PostMapping("/Added")
    public Map<String,Object> AddJ(@RequestParam("files") MultipartFile file,int parkimgType, HttpSession session,EpActivity epActivity){
        return epActvityService.imageuploadJ(file,parkimgType,session,epActivity);
    }
    @PostMapping("/Addeds")
    public Map<String,Object> AddJ( HttpSession session,EpActivity epActivity){
        return epActvityService.imageuploadJj(session,epActivity);
    }
}
